﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace eschoolBO
{
    public class attendence
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _day_id = -99;
        private string _date = "";
        private long _class_id = -99;
        private long _subject_id = -99;
        private long _student_id = -99;
        private string _sattendence = "";
        private string _reason = "";
        private bool _leave = false;
        private bool _isdeleted = false;
        public long day_id
        {
            get
            {
                return _day_id;
            }
            set
            {
                _day_id = value;
            }
        }
        public string date
        {
            get
            {
                return _date;
            }
            set
            {
                _date = value;
            }
        }
        public long class_id
        {
            get
            {
                return _class_id;
            }
            set
            {
                _class_id = value;
            }
        }
        public long subject_id
        {
            get
            {
                return _subject_id;
            }
            set
            {
                _subject_id = value;
            }
        }
        public long student_id
        {
            get
            {
                return _student_id;
            }
            set
            {
                _student_id = value;
            }
        }
        public string sattendence
        {
            get
            {
                return _sattendence;
            }
            set
            {
                _sattendence = value;
            }
        }
        public string reason
        {
            get
            {
                return _reason;
            }
            set
            {
                _reason = value;
            }
        }
        public bool leave
        {
            get
            {
                return _leave;
            }
            set
            {
                _leave = value;
            }
        }
        public bool isdeleted
        {
            get
            {
                return _isdeleted;
            }
            set
            {
                _isdeleted = value;
            }
        }
        public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@day_id", day_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@date", date, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@class_id", class_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@subject_id", subject_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@student_id", student_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@attendence", sattendence, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@reason", reason, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@leave", leave, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam8 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6, dbparam7, dbparam8 };
                return DAC.Save("attendence_save", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long day_id, string date, long class_id, long subject_id, long student_id, char attendence, string reason, bool leave, bool isdeleted, string paraandor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@day_id", day_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@date", date, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@class_id", class_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@subject_id", subject_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@student_id", student_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("sattendence", sattendence, DbType.StringFixedLength, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@reason", reason, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@leave", leave, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam8 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam9 = DAC.Parameter("@paraandor", paraandor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6, dbparam7, dbparam8, dbparam9 };
                DataTable dt1 = DAC.Select("attendence_get", dbparamcall);
                return dt1;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }
    }
}
